package org.example.project.bookstore.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.example.bean.Alipay;
import org.example.project.bookstore.service.AlipayService;
import org.example.util.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther:Liu
 * @Testname:AlipayController
 * @Date:2025/8/26 11:09
 */
@RestController
@RequestMapping("/alipay")
public class AlipayController {
    @Resource
    private AlipayService alipayService;

    private String orderId,logisticsId1;

    @GetMapping("/pay")
    public String pay(Alipay alipay,String logisticsId) {
        orderId=alipay.getOut_trade_no();
        this.logisticsId1=logisticsId;
        return alipayService.pay(alipay, logisticsId);
    }

    @GetMapping("/success")
    public JsonResult query(){
        return alipayService.query(orderId,this.logisticsId1);
    }
}
